<template>
	<div class="layout">
		<div class="goods-cell-title">
			<h4 class="h4">{{ res.title }}</h4>
		</div>
		<div class="goods-list">
			<div @click="handleClick(item)" class="goods-item" v-for="(item, item_index) in res.list" :key="item_index">
				<div class="goods-img">
					<u-image :src="item.thumbnail" height="345rpx" mode="aspectFill" width="100%">
						<u-loading slot="loading"></u-loading>
					</u-image>
				</div>
				<div class="goods-desc">
					<div class="goods-title">
						{{ item.goodsName }}
					</div>
					<div class="goods-bottom">
						<div class="goods-price">
							¥<span>{{ $options.filters.goodsFormatPrice(item.price)[0] }}
							</span>.{{ $options.filters.goodsFormatPrice(item.price)[1] }}
						</div>

					</div>
				</div>
			</div>

		</div>
	</div>
</template>
<script>
	export default {
		data() {
			return {

			};
		},
		props: ["res"],
		// watch: {
		// 	res: {
		// 		handler(val) {
		// 			// 监听父级的值 如果有值将值赋给selected
		// 			if (val) {
		// 				console.log(val)
		// 				// 如果第一个标签页绑定为商品
		// 				this.selected.val = this.res.list[0].listWay[0] ? this.res.list[0].listWay[0].type : '';
		// 				// 如果第一个标签为绑定为分类
		// 				this.res.list[0].titleWay[0].bindCategory ? this.initGoods(this.res.list[0].titleWay[0]) : ''
		// 			}
		// 		},
		// 		immediate: true,
		// 	},
		// },
		mounted() {

		},
		destroyed() {},
		methods: {
			handleClick(item) {
				uni.navigateTo({
					url: item.pUrl,
				});
			},
		},
	};
</script>
<style lang="scss" scoped>
	$w_94: 100%;

	.layout {
		// padding: 8px 0;
		// background: #F4F4F4;
		// width: 710rpx;
		// margin: 0 auto;
	}

	.selected-title {
		>h4 {
			font-size: 30rpx;
			color: #000 !important;
		}

		>div {
			font-weight: bold;
			color: $main-color !important;
		}
	}

	.goods-cell-title {
		background: #F4F4F4;
		padding: 20rpx;
		transition: 0.35s;
		display: flex;

		h4 {
			font-size: 32rpx;
		}
	}

	.goods-list {
		width: 100%;
		display: flex;
		flex-wrap: wrap;
	}

	.goods-item {
		// width: 50%;
		width: 345rpx;
		margin-bottom: 10px;
		border-radius: 0.4em;
		overflow: hidden;
		margin-left: 20rpx;
	}

	.goods-img {
		position: relative;
		margin: 0 auto;
		// width: 158px;
		width: $w_94;
		border-top-left-radius: 20rpx;
		border-top-right-radius: 20rpx;
		overflow: hidden;

		>img {
			width: 100%;
			height: 100%;
		}
	}

	.goods-desc {
		border-bottom-left-radius: 20rpx;
		border-bottom-right-radius: 20rpx;
		width: $w_94;
		background: #fff;
		// padding: 8rpx 0 8rpx 8rpx;
		padding: 8rpx;
		margin: 0 auto;

		>.goods-title {
			font-size: 24rpx;
			height: 67rpx;
			display: -webkit-box;
			font-weight: 500;
			-webkit-box-orient: vertical;
			-webkit-line-clamp: 2;
			overflow: hidden;
		}

		>.goods-bottom {
			display: flex;
			font-weight: bold;
			align-items: center;

			>.goods-price {
				line-height: 2;
				color: $main-color;

				>span {
					font-size: 42rpx;
				}
			}
		}
	}
</style>